<?php
	include("function.php");

	if(isset($_GET["user_latitude"]) && isset($_GET["user_longitude"]) && !empty($_GET["max_km"])){

		$user_latitude = floatval($_GET['user_latitude']);
		$user_longitude = floatval($_GET['user_longitude']);
		$max_km = $_GET['max_km'];

		try{

                        $array = show_bitches();

                        $verified_bitches = array();

                        foreach ($array as $bitch) {
                            $bitch_latitude = floatval($bitch["latitude"]);
                            $bitch_longitude = floatval($bitch["longitude"]);

                            if(distance($user_latitude, $user_longitude, $bitch_latitude, $bitch_longitude, "K") <= $max_km){
                                    array_push($verified_bitches, $bitch);        	
                            }
                        }

                    echo json_encode($verified_bitches);
                 }
                 catch(Exception $e){
	        echo "Error GET ALL db";
	    }
	}


	
	